package com;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;

public class test {

	public static void main(String[] args) throws Exception {
//		Integer aInteger=new Integer(1);
//		System.out.println(aInteger==1);

//		LocalDateTime now = LocalDateTime.now();
//		System.out.println(now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")));

//		String temperatureValue = "3800";
//		
//		temperatureValue = temperatureValue.substring(0, temperatureValue.length() - 2);
//
//		System.out.println(temperatureValue);

		while (true) {
			Calendar ca = Calendar.getInstance();
			TimeZone tz = ca.getTimeZone();
			System.out.println("当前时区：" + tz.getID());

			LocalDateTime now = LocalDateTime.now();
			System.out.println("本地时间1：" + now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")));

			java.util.Date date = new java.util.Date();
			Instant instant = date.toInstant();
			ZoneId zone = ZoneId.systemDefault();
			LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, zone);
			String date1 = localDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"));
			System.out.println("本地时间2：" + date1);

			Date date2 = new Date();
			DateFormat bf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
			System.out.println("本地时间3：" + bf.format(date2));
			
			long currentTime = System.currentTimeMillis();
			SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm");
			Date datex = new Date(currentTime);
			System.out.println("本地时间4：" +formatter.format(datex));
			
			Thread t1 = new Thread(new Runnable() {
				public void run() {
					long currentTime = System.currentTimeMillis();
					SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm");
					Date datex = new Date(currentTime);
					System.out.println("本地时间5：" +formatter.format(datex));
				}
			});
			t1.start();
			
			ZonedDateTime zonedDateTime = ZonedDateTime.now();
			System.out.println("本地时间6：" + zonedDateTime);

			Thread.sleep(2000);

		}
		
		// Java调用 dos命令
//        String cmd = "tzutil /g";
//        try {
//            Process process = Runtime.getRuntime().exec(cmd);
//            InputStream is = process.getInputStream();
//            InputStreamReader isr = new InputStreamReader(is);
//            BufferedReader br = new BufferedReader(isr);
//            
//            String content = br.readLine();
//            while (content != null) {
//                System.out.println(content);
//                content = br.readLine();
//            }
//            //杀掉进程
//            process.destroy();
//        } catch (IOException e) {
//            e.printStackTrace();
//        }

//    	for(String key : "memoryCheckOne,memoryCheckTwo,memoryCheckThree,memoryCheckFour,memoryCheckFive,memoryCheckSix".split(",")) {
//    		System.out.println(key);
//    	}

	}
}
